package cn.zhangxh.org.service;

import cn.zhangxh.App;
import cn.zhangxh.org.BaseTest;
import cn.zhangxh.org.domain.Department;
import cn.zhangxh.org.domain.Employee;
import cn.zhangxh.org.mapper.DepartmentMapper;
import cn.zhangxh.org.query.DepartmentQuery;
import cn.zhangxh.org.service.IDepartmentService;
import cn.zhangxh.org.service.impl.DepartmentServiceImpl;
import cn.zhangxh.util.PageInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.sql.SQLOutput;
import java.util.List;

/**
 * @param :
 * @Author zxh
 * @Date: 2022/1/18$ 11:54$
 * @Version 1.0
 * @return :
 * @Description: test$
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = App.class)
public class test extends BaseTest {

    @Autowired
    private DepartmentMapper departmentMapper;
    @Autowired
    private IDepartmentService departmentService;
    @Autowired
    private IEmployeeService employeeService;

    @Test
    public void querypage(){
        DepartmentQuery query = new DepartmentQuery();
        PageInfo<Department> departmentPageInfo = departmentService.queryPage(query);
        System.out.println(departmentPageInfo);
    }
    @Test
    public void queryById(){
        //departmentMapper.queryAll().forEach(System.out::println);
        Department department = departmentService.queryById(27L);
        System.out.println(department);
    }

    @Test
    public void queryall(){
        List<Department> list = departmentService.queryAll();
        list.forEach(System.out::println);
    }

    @Test
    public void test(){
        Department department = departmentService.queryById(27L);
        department.setId(null);
        departmentService.save(department);
    }

    @Test
    public void update(){
        Department department = departmentService.queryById(46L);
        department.setName("花花鼓励我");
        departmentService.update(department);
    }

    @Test
    public void dete(){
        departmentService.delete(46L);
    }

    @Test
    public void testemp(){
        List<Employee> employees = employeeService.queryAll();
        System.out.println(employees);
    }



}
